<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="keywords" content="jquery,ui,easy,easyui,web">
    <meta name="description" content="easyui help you build your web page easily!">
    <title>jQuery EasyUI Demo</title>
    <link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.3/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.3/themes/icon.css">
    <script type="text/javascript" src="/static/jquery-easyui-1.5.3/jquery.min.js"></script>
    <script type="text/javascript" src="/static/jquery-easyui-1.5.3/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/static/jquery-easyui-1.5.3/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/static/plugin/moment.js"></script>
    <script src="/static/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
    <script src="/static/jquery-file-upload/js/jquery.iframe-transport.js"></script>
    <script src="/static/jquery-file-upload/js/jquery.fileupload.js"></script>
    <script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-detailview.js"></script>

    <script>

        jQuery(function () {

            $('#acquisitionTab').datagrid({
                view: detailview,//注意1
                title: '我的取数',
                url:'/pages/user/list',
                fitColumns: true,
                singleSelect:true,
                height: 340,
                pagination: true,
                columns: [
                        {field: 'id', checkbox: true },
                        {field: 'code', title: '任务编号'},
                        {field: 'templateName', title: '主 题',width:50},
                        {field: 'topic', title: '取数目的',width:50}
                        ],
            detailFormatter:function(index,row){//注意2
                return '<div style="padding:2px"><table id="ddv-' + index + '"></table></div>';
            },
            onExpandRow:function(index,row){//注意3
                $('#ddv-'+index).datagrid({
                    url:"/pages/user/list",
                    fitColumns:true,
                    singleSelect:true,
                    height:'auto',
                    columns:[[
                        {field:'taskId',title:'统计任务ID'},
                        {field:'taskName',title:'任务名称',width:50},
                        {field:'taskStatue',title:'任务状态',formatter:function(value, row, index){
                            if (value) {
                                switch (value) {
                                    case '0':
                                        return '任务创建';
                                        break;
                                    case '1':
                                        return '待执行';
                                        break;
                                    case '2':
                                        return '执行中';
                                        break;
                                    case '3':
                                        return '执行成功';
                                        break;
                                    case '4':
                                        return '执行失败';
                                        break;
                                    case '-1':
                                        return '任务取消';
                                        break;
                                    default :
                                        return '已删除';
                                        break;
                                }
                            }
                        }},
                        {field:'taskType',title:'任务说明',width:100},
                        {field:'statisticOpera',title:'任务操作',width:50,align:'center',
                            formatter:function(value, row, index){
                                if(row.taskStatue != '-2'){
                                    var tdContext = '<a href="#this" onclick="removeStatistic('+(row.taskId)+')">删除</a>  ';
                                }
                                return tdContext;
                            }}
                    ]],
                    onResize:function(){
                        $('#acquisitionTab').datagrid('fixDetailRowHeight',index);
                    },
                    onLoadSuccess:function(){
                        setTimeout(function(){
                            $('#acquisitionTab').datagrid('fixDetailRowHeight',index);
                        },0);
                    }
                });
                $('#acquisitionTab').datagrid('fixDetailRowHeight',index);
            }

        });

        });



    </script>
</head>

<body > <table id="acquisitionTab"></table>

</body>
</html>